home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / util / misc / tnm.lha / thumbnailmaker / ThumbNailMaker.rexx < prev   
OS/2 REXX Batch file  |  1999-01-21  |  16KB  |  478 lines

  1. /*
  2. $VER: ThumbNailMaker.rexx 1.3 (1998-12-04)
  3. */
  4. options results
  5. call init
  6. call Tags()
  7. if arg(1)="ABOUT" then do
  8. options results;address ThumbNailMaker;
  9. window ID DOOS Title '"About ThumbNailMaker v1.3"' COMMAND '"window ID DOOS close"' PORT ThumbNailMaker;
  10. text label "\033c\033bThumbNailMaker v1.3\033n\n\033cFreely Distributable Emailware\n\n\033cPlease visit my homepage:\nhttp://members.xoom.com/snorslex/\n\nPlease E-Mail me if you like/hate the program!\nSnorsleX@SoftHome.net\n\n\033r©Copyright 1998 Lorens Johansson"
  11. button ID CAB COMMAND '"ThumbNailMaker.rexx CLOSEABOUT"' ATTRS MUIA_CycleChain 1 label "Okey";
  12. endwindow;
  13. exit
  14. end
  15. if arg(1)="CLOSEABOUT" then do
  16. address ThumbNailMaker;
  17. window ID DOOS close;
  18. exit
  19. end
  20. if arg(1)="USEPREFS" then do
  21. call prefs("u")
  22. exit
  23. end
  24. if arg(1)="SAVEPREFS" then do
  25. call prefs("u")
  26. call prefs("s")
  27. exit
  28. end
  29. if arg(1)="START" then do
  30. call Readstrings
  31. call start
  32. exit
  33. end
  34. address ThumbNailMaker
  35. MUIA_Window_ScreenTitle =              0x804234b0 
  36. window ID DOOM TITLE '"ThumbNailMaker v1.3"' COMMAND '"quit"' PORT ThumbNailMaker ATTRS MUIA_Window_ScreenTitle '"ThumbNailMaker 1.3          ©1998 Lorens Johansson Freely Distributable Emailware"'
  37. menu LABEL "ThumbNailMaker"
  38. item COMMAND '"method 'MUIM_Application_AboutMUI' 0"' PORT ThumbNailMaker  ATTRS MUIA_Menuitem_Shortcut 'M' LABEL "About MUI"
  39. item COMMAND '"ThumbNailMaker.rexx ABOUT"' ATTRS MUIA_Menuitem_Shortcut 'A' LABEL "About"
  40. item ATTRS MUIA_Menuitem_Title '-1'
  41. item COMMAND '"quit"' PORT ThumbNailMaker ATTRS MUIA_Menuitem_Shortcut 'Q' LABEL "Quit"
  42. endmenu
  43. menu LABEL "Settings"
  44. item COMMAND '"ThumbNailMaker.rexx USEPREFS"' ATTRS MUIA_Menuitem_Shortcut 'U' LABEL "Use Prefs..."
  45. item COMMAND '"ThumbNailMaker.rexx SAVEPREFS"' ATTRS MUIA_Menuitem_Shortcut 'S' LABEL "Save Prefs..."
  46. item ATTRS MUIA_Menuitem_Title '-1'
  47. item COMMAND '"method 'MUIM_Application_OpenConfigWindow'"' PORT ThumbNailMaker LABEL "MUI Prefs..."
  48. endmenu
  49. text help '"ThumbNailMaker v1.3 by\nLorens Johansson (http://members.xoom.com/snorslex)\nIf you use this program, you are required to\nEmail the author (SnorsleX@SoftHome.net). Otherwise,\nhow is he supposed to know to keep supporting\nThumbNailMaker ?!?\n\033rLorens Johansson"' label "\033c\033bThumbNailMaker v1.3\033n\n\033cLorens Johansson\n\033cFreely Distributable Emailware"
  50. group REGISTER ID MAIR  ATTRS MUIA_CycleChain 1 LABELS "GFXCon Settings,HTML Settings,General settings"
  51. group 
  52. group ATTRS MUIA_Group_Columns 2
  53. label "GFXCon path:"
  54. string ID CPATH ATTRS MUIA_CycleChain 1 help '"The path to GFXCon, including the executeable file!"'
  55. label "ThumbNail size X:"
  56. string ID CSIZX ATTRS MUIA_CycleChain 1 help '"The horizontal size of the ThumbNails!"'
  57. label "ThumbNail size Y:"
  58. string ID CSIZY ATTRS MUIA_CycleChain 1 help '"The vertical size of the ThumbNails!"'
  59. label "JPEG Quality:"
  60. string ID CJPGQ ATTRS MUIA_CycleChain 1 help '"The quality of the thumbnails. (Only affects JPEG pictures!)"'
  61. label "ThumbNail format:"
  62. string ID CPICF ATTRS MUIA_CycleChain 1 help '"Which format the ThumbNails should be! For example gif or jpg."'
  63. endgroup
  64. endgroup 
  65. group 
  66. group horiz
  67. group  ATTRS MUIA_Group_Columns 4
  68. label "Pics per page:"
  69. string ID HPPP ATTRS MUIA_CycleChain 1 help '"How many ThumbNails each index page should have."'
  70. label "Picture page:"
  71. check ID HPP ATTRS 0x8042654b 0 MUIA_CycleChain 1 MUIA_Selected 1 help '"Check this if the pictures should have an HTML page!"'
  72. endgroup
  73. endgroup
  74. group  ATTRS MUIA_Group_Columns 4
  75. label "X Resolution:"
  76. string ID HXRES ATTRS MUIA_CycleChain 1 help '"Which horizontal resolution the page should be optimized for!"'
  77. label "Frame border:"
  78. string ID HBORD ATTRS MUIA_CycleChain 1 help '"How thick the border of the frames should be!"'
  79. endgroup
  80. group  ATTRS MUIA_Group_Columns 2
  81. label "BGColor:"
  82. string ID HBGCO ATTRS MUIA_CycleChain 1 help '"Which color the HTML files BGs should be!"'
  83. endgroup
  84. group frame label "HTML Information"
  85. group  ATTRS MUIA_Group_Columns 2
  86. label "Base:"
  87. string ID HBASE ATTRS MUIA_CycleChain 1 help '"What text it would be in the base of the index HTML files! You can use HTML tags too."'
  88. label "Header:"
  89. string ID HHEAD ATTRS MUIA_CycleChain 1 help '"What text it would be in the header of the index HTML files! You can use HTML tags too."'
  90. label "Footer:"
  91. string ID HFOOT ATTRS MUIA_CycleChain 1 help '"What text it would be in the footer of the index HTML files! You can use HTML tags too."'
  92. endgroup
  93. endgroup
  94. group frame label "HTML Picture page Information"
  95. group  ATTRS MUIA_Group_Columns 2
  96. label "Base:"
  97. string ID HPBAS ATTRS MUIA_CycleChain 1 help '"What text it would be in the base of the picture HTML files! You can use HTML tags too."'
  98. label "Header:"
  99. string ID HPHEA ATTRS MUIA_CycleChain 1 help '"What text it would be in the header of the picture HTML files! You can use HTML tags too."'
  100. label "Footer:"
  101. string ID HPFOO ATTRS MUIA_CycleChain 1 help '"What text it would be in the footer of the picture HTML files! You can use HTML tags too."'
  102. endgroup
  103. endgroup
  104. endgroup 
  105. group 
  106. group ATTRS MUIA_Group_Columns 2
  107. label "Filepattern:"
  108. string ID GPATT ATTRS MUIA_CycleChain 1 help '"Which files the program should ignore! This is a normal requester pattern."'
  109. label "Source directory:"
  110. popasl ID GDIR ATTRS MUIA_CycleChain 1 help '"The directory where the pictures are!"'
  111. endgroup
  112. group ATTRS MUIA_Group_Columns 4
  113. label "ThumbNail dest dir:"
  114. string ID GTDR ATTRS MUIA_CycleChain 1 help '"The name of the subdirectory where the ThumbNails should be stored,\n ONLY a name no path or slash."'
  115. label "Verbose:"
  116. check ID VERBO ATTRS   0x8042654b MUIA_CycleChain 1 Selected 1 help '"Puts >NIL: in the commandline!"'
  117. endgroup
  118. endgroup 
  119. endgroup
  120. group ATTRS MUIA_Group_Columns 3
  121. button ID START ATTRS MUIA_CycleChain 1 help '"Starts making thumbnails and HTML pages if chosen!"' COMMAND """ThumbNailMaker.rexx START""" label "Start"
  122. button ID ABT ATTRS MUIA_CycleChain 1 help '"Shows some info about ThumbNailMaker."' COMMAND """ThumbNailMaker.rexx ABOUT""" label "About"
  123. button ID QUIT ATTRS MUIA_CycleChain 1 help '"Quits ThumbNailMaker."' COMMAND '"quit"' PORT ThumbNailMaker label "Quit"
  124. endgroup
  125. endwindow
  126. options results;address ThumbNailMaker;
  127. if open(set,'envarc:ThumbNailMaker/Strings', 'R') then do;
  128. Address ThumbNailMaker string ID CPATH content readln(set);
  129. Address ThumbNailMaker string ID CSIZX content readln(set);
  130. Address ThumbNailMaker string ID CSIZY content readln(set);
  131. Address ThumbNailMaker string ID CJPGQ content readln(set);
  132. Address ThumbNailMaker string ID CPICF content readln(set);
  133. Address ThumbNailMaker string ID HPPP content readln(set);
  134. test = readln(set)
  135. if test = 1 then Address ThumbNailMaker check ID HPP ATTRS MUIA_Selected 1
  136. Address ThumbNailMaker string ID HXRES content readln(set);
  137. Address ThumbNailMaker string ID HBORD content readln(set);
  138. Address ThumbNailMaker string ID HBGCO content readln(set);
  139. Address ThumbNailMaker string ID HBASE content readln(set);
  140. Address ThumbNailMaker string ID HHEAD content readln(set);
  141. Address ThumbNailMaker string ID HFOOT content readln(set);
  142. Address ThumbNailMaker string ID HPBAS content readln(set);
  143. Address ThumbNailMaker string ID HPHEA content readln(set);
  144. Address ThumbNailMaker string ID HPFOO content readln(set);
  145. Address ThumbNailMaker string ID GPATT content readln(set);
  146. Address ThumbNailMaker popasl ID GDIR content readln(set);
  147. Address ThumbNailMaker string ID GTDR content readln(set);
  148. test = readln(set)
  149. if test = 1 then Address ThumbNailMaker check ID VERBO ATTRS MUIA_Selected 1
  150. call close(set);
  151. end;
  152. Address ThumbNailMaker
  153. EXIT
  154. Tags:
  155. MUIA_Application_Sleep = 0x80425711
  156. MUIA_AppMessage = 0x80421955
  157. MUIA_Frame = 0x8042ac64
  158. MUIA_Numeric_Value = 0x8042ae3a
  159. MUIA_Menuitem_Title = 0x804218be
  160. MUIA_Menuitem_Shortcut = 0x80422030
  161. MUIA_Selected = 0x8042654b
  162. MUIA_CycleChain = 0x80421ce7
  163. MUIA_Group_Columns = 0x8042f416
  164. MUIA_Group_Rows = 0x8042b68f
  165. MUIA_Disabled = 0x80423661
  166. MUIA_Cycle_Active = 0x80421788
  167. MUIM_Application_AboutMUI = 0x8042d21d
  168. MUIM_Application_OpenConfigWindow = 0x804299ba
  169. TRUE = 1
  170. FALSE = 0
  171. Return 0
  172. c:
  173. address ThumbNailMaker;check id arg(1);
  174. if result = 1 then ct = ct || arg(2);
  175. return 0;
  176. exit
  177. Req:
  178. request ID REQU TITLE '"' arg(1) '"' GADGETS '"_OK"' STRING arg(2)
  179. Return 0
  180. Readstrings:
  181. address ThumbNailMaker;
  182. string ID CPATH
  183. GFXCON = result
  184. string ID CSIZX
  185. sizex = result
  186. string ID CSIZY
  187. sizey = result
  188. string ID CJPGQ
  189. QUALITY = result
  190. string ID CPICF
  191. FORMAT = result
  192. string ID HPPP
  193. perpage = result
  194. check ID HPP
  195. picpage = result
  196. string ID HXRES
  197. res = result
  198. string ID HBORD
  199. BORDER = result
  200. string ID HBGCO
  201. BGCOLOR = result
  202. string ID HBASE
  203. BASE = result
  204. string ID HHEAD
  205. HEADER = result
  206. string ID HFOOT
  207. FOOTER = result
  208. string ID HPBAS
  209. PBASE = result
  210. string ID HPHEA
  211. PHEADER = result
  212. string ID HPFOO
  213. PFOOTER = result
  214. string ID GPATT
  215. PATTERN = result
  216. popasl ID GDIR
  217. directory = result
  218. string ID GTDR
  219. dest = result
  220. check ID VERBO
  221. VERBOSE = result
  222. return
  223. prefs:
  224. if arg(1) = "s" then call open(set,'envarc:ThumbNailMaker/Strings',w);
  225. if arg(1) = "u" then call open(set,'env:ThumbNailMaker/Strings',w);
  226. address ThumbNailMaker;
  227. string ID CPATH
  228. call writeln(set,result);
  229. string ID CSIZX
  230. call writeln(set,result);
  231. string ID CSIZY
  232. call writeln(set,result);
  233. string ID CJPGQ
  234. call writeln(set,result);
  235. string ID CPICF
  236. call writeln(set,result);
  237. string ID HPPP
  238. call writeln(set,result);
  239. check ID HPP
  240. call writeln(set,result);
  241. string ID HXRES
  242. call writeln(set,result);
  243. string ID HBORD
  244. call writeln(set,result);
  245. string ID HBGCO
  246. call writeln(set,result);
  247. string ID HBASE
  248. call writeln(set,result);
  249. string ID HHEAD
  250. call writeln(set,result);
  251. string ID HFOOT
  252. call writeln(set,result);
  253. string ID HPBAS
  254. call writeln(set,result);
  255. string ID HPHEA
  256. call writeln(set,result);
  257. string ID HPFOO
  258. call writeln(set,result);
  259. string ID GPATT
  260. call writeln(set,result);
  261. popasl ID GDIR
  262. call writeln(set,result);
  263. string ID GTDR
  264. call writeln(set,result);
  265. check ID VERBO
  266. call writeln(set,result);
  267. call close(set);
  268. return
  269. start:
  270. form="."||format
  271. form=compress(form,"e")
  272. files=filelist(directory''PATTERN,filenames,F,)
  273. if (files==0) then do
  274. say "No files to process!"
  275. exit 0
  276. end
  277. if ~exists(directory||dest) then call makedir(directory||dest)
  278. dest=dest||"/"
  279. call sort()
  280. say "Checking for new pictures..."
  281. do f=1 to files
  282. name= filenames.f
  283. name2 = name
  284. plats = pos(':',name2)
  285. if plats ~= '0' then name2 = delstr(name2, 1, plats)
  286. do until pos('/',name2) = '0'
  287. plats = pos('/',name2)
  288. if plats ~= '0' then name2 = delstr(name2, 1, plats)
  289. end
  290. call pragma("STACK",22000)
  291. parse var name2 file "." .
  292. file2 = file
  293. plats = pos(':',file2)
  294. if plats ~= '0' then file2 = delstr(file2, 1, plats)
  295. do until pos('/',file2) = '0'
  296. plats = pos('/',file2)
  297. if plats ~= '0' then file2 = delstr(file2, 1, plats)
  298. end
  299. names.f="t_"||file2||FORM
  300. if ~exists(directory||dest||names.f) then do
  301. comm = GFXCON||' "'||name'"'
  302. IF(VERBOSE==1) THEN do
  303. comm = comm||' >NIL:'
  304. say "Processing file "name2
  305. end
  306. comm = comm||' TO "'||directory||dest||names.f||'" FORMAT 'FORMAT
  307. IF (UPPER(FORM)==".JPG") THEN DO
  308. comm = comm||' QUALITY 'QUALITY||' '
  309. END
  310. comm = comm||' BOXFIT '||sizex||' '||sizey
  311. ADDRESS COMMAND comm
  312. end
  313. if ~exists(directory''dest||names.f) then say "Error, GfxCon could not create the thumbnail!"
  314. END
  315. if res="" then res=800
  316. if perpage ==0 then perpage=files
  317. number=1
  318. pagefiles=perpage
  319. pages=files%perpage
  320. if files//perpage ~=0 then pages=pages+1
  321. line="0a"x||"Creating "pages" index page"
  322. if pages>1 then line=line||"(s)"
  323. if picpage==1 then line=line||" and "files" picture pages"
  324. say line||"0a"x
  325. do p=1 to pages
  326. if files-(perpage*p)<0 then pagefiles=files//perpage
  327. if pagefiles>0 then do
  328. max = res % ((border*2)+sizex+7) 
  329. if (pagefiles//max) ~=0  then do 
  330. mostremainders=pagefiles//max
  331. do temp=max to 2 by -1 
  332. if pagefiles//temp > mostremainders then do 
  333. mostremainders=pagefiles//temp
  334. max=temp
  335. end
  336. end
  337. end
  338. rows = pagefiles%max
  339. if pagefiles//max ~=0 then rows=rows+1
  340. indexfile="output"
  341. if open(indexfile,directory||"t_index"||p||".html","W") then do
  342. say "Creating index page #"||p||"..."
  343. call writeln(indexfile,"<HTML>")
  344. call writeln(indexfile,'<BODY BGCOLOR="'BGCOLOR'">')
  345. call writeln(indexfile,BASE)
  346. call writeln(indexfile,HEADER)
  347. call writeln(indexfile,"<CENTER>"||"0a"x||"<BR>")
  348. line=''
  349. do f=1 to pages
  350. if f==p then
  351. line=line||'<A HREF="t_index'||f||'.html"><B>'||f||' </B></A>'
  352. else
  353. line=line||'<A HREF="t_index'||f||'.html">'||f||' </A>'
  354. end
  355. if pages>1 then call writeln(indexfile,line||"0a"x||"<BR>")
  356. call writeln(indexfile,'<TABLE BORDER="'||border||'">')
  357. call pragma("STACK",22000)
  358. do rows
  359. call writeln(indexfile,'<TR ALIGN="CENTER">')
  360. do max
  361. if number-(perpage*(p-1))>pagefiles then iterate
  362. comm=GFXCON||' >T:thumbinfo "'||directory||dest||names.number||'" info'
  363. fileinfo="fileinfo"
  364. address command comm
  365. call open(fileinfo,"T:thumbinfo","r")
  366. do 4
  367. info=readln(fileinfo)
  368. end
  369. parse var info "input size: " thumbx "x" thumby .
  370. thumbx = strip(thumbx,,' ')
  371. call close(fileinfo)
  372. plats = pos(':',filenames.number)
  373. if plats ~= '0' then filenames = delstr(filenames.number, 1, plats)
  374. do until pos('/',filenames) = '0'
  375. plats = pos('/',filenames.number)
  376. if plats ~= '0' then filenames = delstr(filenames.number, 1, plats)
  377. end
  378. if picpage then call writeln(indexfile,'   <TD><A HREF="'||filenames||'.html"><IMG SRC="'||dest||names.number||'" ALT="'||filenames||'" WIDTH="'||thumbx||'" HEIGHT="'||thumby||'" BORDER="0"></A></TD>')
  379. else
  380. call writeln(indexfile,'   <TD><A HREF="'||filenames||'"><IMG SRC="'||dest||names.number||'" ALT="'||filenames||'" WIDTH="'||thumbx||'" HEIGHT="'||thumby||'" BORDER="0"></A></TD>')
  381. if picpage then do
  382. line1=''
  383. if open(picfile,filenames.number||".html","W") then do
  384. call writeln(picfile,"<HTML>")
  385. call writeln(picfile,'<BODY BGCOLOR="'BGCOLOR'">')
  386. call writeln(picfile,PBASE)
  387. call writeln(picfile,PHEADER)
  388. call writeln(picfile,"<CENTER>"||"0a"x||"<BR>")
  389. comm=GFXCON||' >T:thumbinfo "'||filenames.number||'" info'
  390. fileinfo="fileinfo"
  391. address command comm
  392. call open(fileinfo,"T:thumbinfo","r")
  393. do 4
  394. info=readln(fileinfo)
  395. end
  396. parse var info "input size: " thumbx "x" thumby .
  397. call close(fileinfo)
  398. call writeln(picfile,'<IMG SRC="'||filenames||'" WIDTH="'||thumbx||'" HEIGHT="'||thumby||'"><BR><PRE>')
  399. prev=number-1; next=number+1
  400. plats = pos(':',filenames.prev)
  401. if plats ~= '0' then filenamesprev = delstr(filenames.prev, 1, plats)
  402. do until pos('/',filenamesprev) = '0'
  403. plats = pos('/',filenames.prev)
  404. if plats ~= '0' then filenamesprev = delstr(filenames.prev, 1, plats)
  405. end
  406. plats = pos(':',filenames.next)
  407. if plats ~= '0' then filenamesnext = delstr(filenames.next, 1, plats)
  408. do until pos('/',filenamesnext) = '0'
  409. plats = pos('/',filenames.next)
  410. if plats ~= '0' then filenamesnext = delstr(filenames.next, 1, plats)
  411. end
  412. if number>1 then line1='<A HREF="'filenamesprev||'.html">Previous</A>   '
  413. if number<files then line1=line1||'<A HREF="'||filenamesnext||'.html">Next</A>'
  414. call writeln(picfile,line1||"<BR></PRE>")
  415. call writeln(picfile,"Index: "||line)
  416. call writeln(picfile,"</CENTER>")
  417. call writeln(picfile,PFOOTER)
  418. call writeln(picfile,"</BODY>")
  419. call writeln(picfile,"</HTML>")
  420. call close (picfile)
  421. end
  422. else say "  Cannot create picture page file for "||filenames||"!"
  423. end
  424. number=number+1
  425. end
  426. call writeln(indexfile,"</TR>")
  427. end
  428. call writeln(indexfile,"</TABLE>")
  429. if pages>1 then call writeln(indexfile,line||"0a"x||"<BR>")
  430. call writeln(indexfile,"</CENTER>")
  431. call writeln(indexfile,FOOTER)
  432. call writeln(indexfile,"</BODY>")
  433. call writeln(indexfile,"</HTML>")
  434. call close (indexfile)
  435. end
  436. end
  437. else
  438. say " Cannot create index file!!!"
  439. end
  440. call delete("T:thumbinfo")
  441. say "0a"x||"Done."
  442. return
  443. SORT: procedure expose filenames. files
  444. say "Sorting list of files..."
  445. do f=1 to files-1
  446. n=f+1
  447. if filenames.f > filenames.n then do
  448. store=filenames.n
  449. filenames.n=filenames.f
  450. do bubpos=f-1 to 1 by -1 while (store < filenames.bubpos)
  451. n=bubpos+1
  452. filenames.n=filenames.bubpos
  453. end bubpos
  454. bubpos=bubpos+1
  455. filenames.bubpos=store
  456. end
  457. end f
  458. return
  459. init:
  460. lib.0 = 2
  461. lib.1 = "rexxdossupport.library"
  462. lib.2 = "rexxarplib.library"
  463. do x=1 to lib.0
  464. if exists('libs:'lib.x) then do
  465. if ~show('L',lib.x) then call addlib(lib.x,0,-30,0)
  466. end
  467. else do
  468. Address ThumbNailMaker
  469. Req('Library Error','Unable to open 'lib.x)
  470. address ThumbNailMaker ;quit
  471. exit
  472. end
  473. end
  474. R='0A'X
  475. if ~exists('env:ThumbNailMaker') then address command 'makedir env:ThumbNailMaker'
  476. if ~exists('envarc:ThumbNailMaker') then address command 'makedir envarc:ThumbNailMaker'
  477. return
  478.